package com.terren.spider.core.html.configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.terren.spider.core.html.scheme.ICustomScheme;
import com.terren.spider.entity.config.SysConfig;
import com.terren.spider.entity.core.CatagoryType;
import com.terren.spider.entity.core.Entry;
import com.terren.spider.entity.core.ProxyRequestParam;

public class Configuration {
//	/private SpiderType spiderType = SysConfig.DEFUALT_SPIDER_TYPE;//抓取类型  网页 ，搜索引擎 ，app
	
	private CatagoryType catagoryType = SysConfig.CATAGORY_TYPE;//抓取类型  网页 ，搜索引擎 ，新闻 微博等
	private Boolean testMode = false;//测试模式
	
	private Boolean saveBatch = SysConfig.DEFUALT_SAVE_BATCH;
	private Integer saveBatchCount = SysConfig.DEFUALT_SAVE_BATCH_COUNT;
	
	private Boolean saveToDb = SysConfig.DEFUALT_SAVE_TO_DB;
	private Boolean saveToHtml = SysConfig.DEFUALT_SAVE_TO_HTML;
	private Boolean saveToJson = SysConfig.DEFUALT_SAVE_TO_JSON;
	
	
	private Integer retryTimes = SysConfig.RETRY_TIMES;//重试次数
	private Integer sleepTime = SysConfig.SLEEP_TIME;//抓取间隔
	private Integer cycleRetryTimes = SysConfig.CYCLE_RETRY_TIMES;//抓取间隔
	private Integer retrySleepTime = SysConfig.RETRY_SLEEP_TIME;//
	private Integer timeOut = SysConfig.TIME_OUT;//
	private String charset;
	private String domain;
	private String userAgent;//ua
	private Set<Integer> acceptStatCode;
	private Boolean disableCookieManagement = SysConfig.DISABLE_COOKIE_MANAGEMENT;// 是否使用cookie
	private Boolean useGzip = SysConfig.USER_GZIP ;
	private Integer threadNum = SysConfig.THREAD_NUM;//线程数
	private SpiderSchedulerType schedulerType = SysConfig.SCHEDULER_TYPE;//(QueueScheduler使用内存队列保存待抓取URL)对待抓取的URL队列进行管理,对已抓取的URL进行去重。
	private Integer maxLinks;//爬取最大链接数
	
	
	private ProxyRequestParam proxyRequestParam = new ProxyRequestParam();//代理服务器 所需参数
	
	private List<ICustomScheme> schemes = new ArrayList<ICustomScheme>();//自定义方案（分页，列表页等抓取方式）
	private Entry entry;
	
	private Map<String, String> headers;
	private Map<String, String> cookies;
	
	public Integer pageRecordSize;//搜索页  每页显示的条目数
	
	
	
	
	public Integer getPageRecordSize() {
		return pageRecordSize;
	}

	public void setPageRecordSize(Integer pageRecordSize) {
		this.pageRecordSize = pageRecordSize;
	}

	public Entry getEntry() {
		if (null == entry) {
			entry = new Entry();
		}
		return entry;
	}

	public void setEntry(Entry entry) {
		this.entry = entry;
	}

	public Configuration addScheme(ICustomScheme scheme) {
		if (null != scheme) {
			schemes.add(scheme);
		}
		return this;
	}
	
	public List<ICustomScheme> getSchemes() {
		return schemes;
	}
	public void setSchemes(List<ICustomScheme> schemes) {
		this.schemes = schemes;
	}
	public ProxyRequestParam getProxyRequestParam() {
		return proxyRequestParam;
	}
	public void setProxyRequestParam(ProxyRequestParam proxyRequestParam) {
		this.proxyRequestParam = proxyRequestParam;
	}
	
	public Map<String, String> getCookies() {
		return cookies;
	}

	public void setCookies(Map<String, String> cookies) {
		this.cookies = cookies;
	}

	public Map<String, String> getHeaders() {
		return headers;
	}
	public void setHeaders(Map<String, String> headers) {
		this.headers = headers;
	}
	public Integer getMaxLinks() {
		return maxLinks;
	}
	public void setMaxLinks(Integer maxLinks) {
		this.maxLinks = maxLinks;
	}
	public SpiderSchedulerType getSchedulerType() {
		return schedulerType;
	}
	public void setSchedulerType(SpiderSchedulerType schedulerType) {
		this.schedulerType = schedulerType;
	}
	public Integer getThreadNum() {
		return threadNum;
	}
	public void setThreadNum(Integer threadNum) {
		this.threadNum = threadNum;
	}
	public Integer getRetryTimes() {
		return retryTimes;
	}
	public void setRetryTimes(Integer retryTimes) {
		this.retryTimes = retryTimes;
	}
	public Integer getSleepTime() {
		return sleepTime;
	}
	public void setSleepTime(Integer sleepTime) {
		this.sleepTime = sleepTime;
	}
	public Integer getCycleRetryTimes() {
		return cycleRetryTimes;
	}
	public void setCycleRetryTimes(Integer cycleRetryTimes) {
		this.cycleRetryTimes = cycleRetryTimes;
	}
	public Integer getRetrySleepTime() {
		return retrySleepTime;
	}
	public void setRetrySleepTime(Integer retrySleepTime) {
		this.retrySleepTime = retrySleepTime;
	}
	public Integer getTimeOut() {
		return timeOut;
	}
	public void setTimeOut(Integer timeOut) {
		this.timeOut = timeOut;
	}
	public String getCharset() {
		return charset;
	}
	public void setCharset(String charset) {
		this.charset = charset;
	}
	public String getDomain() {
		return domain;
	}
	public void setDomain(String domain) {
		this.domain = domain;
	}
	public String getUserAgent() {
		return userAgent;
	}
	public void setUserAgent(String userAgent) {
		this.userAgent = userAgent;
	}
	public Set<Integer> getAcceptStatCode() {
		return acceptStatCode;
	}
	public void setAcceptStatCode(Set<Integer> acceptStatCode) {
		this.acceptStatCode = acceptStatCode;
	}
	public Boolean getDisableCookieManagement() {
		return disableCookieManagement;
	}
	public void setDisableCookieManagement(Boolean disableCookieManagement) {
		this.disableCookieManagement = disableCookieManagement;
	}
	public Boolean getUseGzip() {
		return useGzip;
	}
	public void setUseGzip(Boolean useGzip) {
		this.useGzip = useGzip;
	}
	public Boolean getSaveToDb() {
		return saveToDb;
	}
	public void setSaveToDb(Boolean saveToDb) {
		this.saveToDb = saveToDb;
	}
	public Boolean getSaveToHtml() {
		return saveToHtml;
	}
	public void setSaveToHtml(Boolean saveToHtml) {
		this.saveToHtml = saveToHtml;
	}
	public Boolean getSaveToJson() {
		return saveToJson;
	}
	public void setSaveToJson(Boolean saveToJson) {
		this.saveToJson = saveToJson;
	}
	public Boolean getSaveBatch() {
		return saveBatch;
	}
	public void setSaveBatch(Boolean saveBatch) {
		this.saveBatch = saveBatch;
	}
	public Integer getSaveBatchCount() {
		return saveBatchCount;
	}
	public void setSaveBatchCount(Integer saveBatchCount) {
		this.saveBatchCount = saveBatchCount;
	}
	public CatagoryType getCatagoryType() {
		return catagoryType;
	}
	public void setCatagoryType(CatagoryType catagoryType) {
		this.catagoryType = catagoryType;
	}
	public Boolean getTestMode() {
		return testMode;
	}
	public void setTestMode(Boolean testMode) {
		this.testMode = testMode;
	}
	
}
